package com.bjsxt.exception;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class Test {

    public static void main(String[] args)  {
        System.out.println("step1");
        try{
            int i=1/0;
        }catch (Exception e){
            e.printStackTrace();
        }
        System.out.println("step2");

        FileReader reader = null;
        try {
            reader = new FileReader("/home/xiaodiyang/job/javaStudy/java300/src/com/bjsxt/exception/a.txt");
            char c = (char)reader.read();
            char c2 = (char)reader.read();
            System.out.println(""+c+c2);

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try{
                if (reader!=null){
                    reader.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        try(FileReader reader2 = new FileReader("/home/xiaodiyang/job/javaStudy/java300/src/com/bjsxt/exception/a.txt");){
            char c = (char)reader2.read();
            char c2 = (char)reader2.read();
            System.out.println(""+c+c2);

        } catch (Exception e) {
            e.printStackTrace();
        }


    }
}
